<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">分配权限</ui:define>
    <ui:define name="content">
        <h:form>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="保存" icon="fa fa-save"
                                         actionListener="#{permissionRelationBean.onSave}" update="@form"
                                         rendered="#{security:areAnyGranted('ROLE_RELATE_PERMISSION,USER_RELATE_PERMISSION')}"/>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"></p:button>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-6">
                    <div class="card">
                        <h1>功能权限</h1>
                        <p:tree value="#{permissionRelationBean.functionalRoot}" var="node"
                                dynamic="true"
                                selectionMode="checkbox"
                                selection="#{permissionRelationBean.selectedFunctionalTreeNodes}"
                                animate="true"
                                expanded="true"
                                propagateSelectionUp="false">

                            <p:treeNode icon="#{node.icon}">
                                <h:outputText
                                        value="#{node.name} #{node.id ==null ? '' : node.enable ? '(启用)' : '(禁用)'}"/>
                            </p:treeNode>
                        </p:tree>
                    </div>
                </div>
                <div class="ui-g-6">
                    <div class="card">
                        <h1>数据限制</h1>
                        <p:tree value="#{permissionRelationBean.dataRoot}" var="node"
                                dynamic="true"
                                selectionMode="checkbox"
                                selection="#{permissionRelationBean.selectedDataTreeNodes}"
                                animate="true"
                                expanded="true"
                                propagateSelectionUp="false">


                            <p:treeNode icon="#{node.icon}">
                                <h:outputText
                                        value="#{node.name} #{node.id ==null ? '' : node.enable ? '(启用)' : '(禁用)'}"/>
                            </p:treeNode>
                        </p:tree>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>